const { defineConfig } = require('@vue/cli-service')
let {list}=require('./src/mock')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer:{
    setupMiddlewares(middlewares,{app}){
      // 模拟注册和登录的API
      app.get('/api/login',(req,res)=>{
        res.send(
          list
        )
      })
      app.get('/api/add',(req,res)=>{
        const {id,user,pwd,token}=req.query
        if(!list.find(v=>v.id===id)){
          list.push(req.query)
        }
        res.send({
          code:200
        })
      })
      return middlewares
    }
  }
})
